package com.moarea.app.dao;

import com.moarea.app.model.BaseDictionary;
import com.sun.istack.internal.Nullable;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * 子类pid=父类id
 */
@Repository
public interface BaseDictionaryMapper extends Mapper<BaseDictionary> {
    List<Map<String, Object>> selectByPcode(@Param("pcode") String pcode);

    List<Map<String, Object>> selectByPcodeNoCode(@Param("pcode") String pcode, @Nullable @Param("name") String name);

    List<BaseDictionary> selectNodeByPcode(@Param("pcode") String pcode);

    List<BaseDictionary> selectEntityByPcode(@Param("pcode") String pcode);

    List<Map<String, Object>> listTreeMenus();

    List<Map<String, Object>> selectByID(@Param("ID") String ID);

    List<BaseDictionary> selectChildrenByPid(@Param("PID") String PID);

    //查询过滤后的子节点
    List<BaseDictionary> selectFilterChildByPid(@Param("LOGINUSER") String loginuser);

    List<Map<String, Object>> selectSupByType(@Param("corp_name") String corp_name);


    Integer selectMaxSeqByPID(@Param("PID") String PID);

    //通过子类PID查父类ID
    String selectFaIDByChildPID(@Param("PID") String PID);

    //通过自己的ID查自己的paraname
    String seleParanameByID(@Param("ID") String id);

    List<BaseDictionary> selectNodeBySupAndSubPcode(@Param("SUP_PCODE") String SUP_PCODE, @Param("SUB_PCODE") String SUB_PCODE);

    List<BaseDictionary> selectParentByPID(@Param("PID") String PID);

    //商品模板导入验证分类(根据用户部门进行过滤)
    String findFilterGCategory(Map<String, Object> param);

    //验证编码是否重复(新增)
    Integer isRepeatByPID(Map<String, Object> map);

    //验证编码是否重复（更新）
    Integer isRepeatByPIDAndID(Map<String, Object> map);

    //删除父节点
    void deleteByID(@Param("ID") String ID);

    //从字典中获取我的首页所有值
    List<Map<String,Object>> selectHomePage(@Param("MY_PAGE") String MY_PAGE, @Param("USERNO") String USERNO);


    List<Map<String,Object>> selectCategoryBydept(@Param("DEPT") String DEPT);

    List<BaseDictionary> selectByParaCode(@Param("pcode") String pcode);

    List<BaseDictionary> selectByPid(Map<String, Object> param);

    BaseDictionary selectByParaName(Map<String, Object> param);
}